package com.fanketly.musicdiary.data.model

import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import java.time.LocalDate

@Entity(tableName = "diary")
data class DiaryModel(
    val year: Int,
    val month: Int,
    val dayOfMonth: Int,
    val content: String,
    val mood: String,
    val imgPath: String,
    val musicID: String? = null,
    @PrimaryKey(autoGenerate = true) var id: Long,
) {
    @Ignore
    constructor(
        year: Int,
        month: Int,
        dayOfMonth: Int,
        content: String = "",
        mood: String = "",
        imgPath: String = "",
        musicID: String? = null,
    ) : this(year, month, dayOfMonth, content, mood, imgPath, musicID, 0)
}

fun newDiaryModel(localDate: LocalDate = LocalDate.now()) =
    DiaryModel(localDate.year, localDate.monthValue, localDate.dayOfMonth)

fun DiaryModel.isMusicEmpty() = musicID == null
fun DiaryModel.isMusicNotEmpty() = musicID != null

